﻿/******************************************************************************************
*                                                                                         *    
*                              Developed by Bruno Pires                                   *
*                                                                                         *
*                             email: bruno@blastersystems.com                             *
*                               web: www.blastersystems.com                               *
*                              blog: www.blastersystems.com/blog                          *
*                           twitter: brunoacpires                                         *
*                                                                                         *
*                      Software available under GNU LGPL v3 License                       *
*                                                                                         *    
* *****************************************************************************************/  
using System;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Generic;
using System.Text;
using System.Globalization;

namespace GoogleMaps.GoogleMaps
{
    public partial class GoogleMapsControl : System.Web.UI.UserControl
    {
        #region Properties and Enumerators
        
        public enum MapStyle
        {
            G_NORMAL_MAP,
            G_SATELLITE_MAP,
            G_HYBRID_MAP,
            G_PHYSICAL_MAP 
        };

        public int zoom { get; set; }
        public string mapContainer { get; set; }
        public MapStyle mapStyle { get; set; }
        public decimal latitude { get; set; }
        public decimal longitude { get; set; }
        public bool pushPin { get; set; }
        public string pushPinTitle { get; set; }
        public string pushPinDescription { get; set; }
        public string MapWidth { get; set; }
        public string MapHeight { get; set; }
        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            InjectJavaScriptBingMaps();
        }

        public void InjectJavaScriptBingMaps()
        {
            StringBuilder javascriptFunction = new StringBuilder();
            javascriptFunction.Append("getGoogleMaps(");
            javascriptFunction.Append("'myMap',");
            javascriptFunction.Append(""  + latitude.ToString(CultureInfo.InvariantCulture.NumberFormat) + ",");
            javascriptFunction.Append(""  + longitude.ToString(CultureInfo.InvariantCulture.NumberFormat) + ",");
            javascriptFunction.Append(""  + zoom + ",");
            javascriptFunction.Append(""  + pushPin.ToString().ToLower() + ",");
            javascriptFunction.Append("'" + pushPinTitle + "',");
            javascriptFunction.Append("'" + pushPinDescription + "',");
            javascriptFunction.Append(""  + mapStyle+",");
            javascriptFunction.Append("'" + MapWidth + "',");
            javascriptFunction.Append("'" + MapHeight + "'");
            javascriptFunction.Append(");");
            Page.ClientScript.RegisterStartupScript(GetType(), "Javascript", javascriptFunction.ToString(), true);
        }
    }
}